<template>
	<view class='content'>
		<uni-nav-bar
		left-icon="back" 
		status-bar=true
		fixed=true
		color="#FFF"
		left-text="返回" 
		right-text="" 
		:title="maintitle"
		:background-color="bgcolor"
		@clickLeft="toback"
		></uni-nav-bar>
		<view v-html="content"></view>
	</view>
	
</template>

<script>
	import api from '@/pages/utils/api.js';
	export default {
		data(){
			return{
				maintitle:"新闻详情",
				bgcolor:"#409ED7",
				id:'',
				typeid:'',
				content:'' 
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.typeid = option.typeid;
			this.getDetails();
		},
		methods:{
			toback:function(){
				uni.navigateBack({
					delta: 1,
					animationType: 'pop-out',
					animationDuration: 200
				});
			},
			
			getDetails:function(){
				uni.showLoading({
				      title: '加载中...'
				  });
				var vm = this;
				api.getDetail({
					id:vm.id,
					type_id:vm.typeid
				}).then(data=>{
					if(data.code == 1){ 
						vm.content = data.data.content;
						uni.hideLoading();
					}else{
						uni.hideLoading();
						uni.showToast({
						    icon: 'none',
						    title: data.msg,
							position:'bottom'
						});
						setTimeout(function(){
							setTimeout(function(){
								vm.toback();
							},1500);
						},2000);
					}
				})
			}
			
		}
	}
</script> 

<style>
	img{
		max-width: 100%;
	}
	iframe{
		max-width: 100%;
		margin-left: -.5rem;
	}
</style>
